package com.aya.activity.goods.descend;

import com.aya.activity.core.GoodsPriceActivity;
import com.aya.activity.core.model.Goods;

import java.math.BigDecimal;

/**
 * 单品直降
 */
public class Descend<T> implements GoodsPriceActivity {
    /**
     * 商品折扣服务
     */
    private DescendService<T>  goodsDescend;


    public void setGoodsDescend(DescendService<T> goodsDescend) {
        this.goodsDescend = goodsDescend;
    }

    public BigDecimal activity(Goods goods, BigDecimal price) {
        return price.subtract(goodsDescend.getDescend(goods.getId()));
    }
}
